<template>
	<view class="box" :style="theme">
		<!-- 会员卡 -->
		<view class="boxImg" :style="{backgroundImage: 'url(' + coverImgUrl + ')'}">
			<view class="box_box">
				<view class="box_image_title">
					<view class="box_image_title_left">
						<view class="box_image_title_left_img">
							<image :src="userInfo.showAvatar ? userInfo.showAvatar : imgHost+'/user.png'"></image>
						</view>
						<view class="box_image_title_left_name">
							<text>{{userInfo.nickName}}</text>
							<text>No.{{userInfo.number}}</text>
						</view>
					</view>
					<view class="box_image_title_right" v-if="userInfo.cardName"><text>{{userInfo.cardName}}</text></view>
				</view>
				<view class="box_image_ye">
					<view>账户余额：</view>
					<view><text class="big">{{userInfo.money}}</text>元</view>
				</view>
			</view>
		</view>
		<!-- 功能区 -->
		<view class="box_list">
		    <view class="box_li flex flex_between" @click="jump('/pages/member/recordsConsumption')">
		    	消费记录 <u-icon name="arrow-right" size="28rpx"></u-icon>
		    </view>
			<view class="box_li flex flex_between" @click="jump('/pages/member/coupon')">
				优惠券 <u-icon name="arrow-right" size="28rpx"></u-icon>
			</view>
			<view class="box_li flex flex_between" @click="jump('/subPackages/setmeal/index')">
				套餐 <u-icon name="arrow-right" size="28rpx"></u-icon>
			</view>
			<view class="box_li flex flex_between" @click="jump('/pages/member/product')">
				课程包 <u-icon name="arrow-right" size="28rpx"></u-icon>
			</view>
		</view>
		<!-- 占位 -->
		<view class="box_zw"></view>
		<!-- 充值按钮 -->
		<view class="box_footer" @click="jumpCZ">
			<view class="box_footer_btn">立即充值</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				info: {},
				coverImgUrl: 'http://zhcg-pro.oss-cn-hangzhou.aliyuncs.com/xiaochengxuditu/lQLPJyJX7wp-AgTNAU7NArKwOIDWsY44SlADqI0THYD_AA_690_334.png'
			}
		},
		onShow() {
			this.getMemberInformation()
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			jumpCZ() {
				if (this.userInfo.isNormal == '1') {
					this.jump('/pages/member/recharge')
				} else {
					this.jump('/pages/member/handle')
				}
			},	
			getMemberInformation() {
				this.$app.ajax({
					data: {
						param: {}
					},
					api: this.$api.memberInformation()
				}).then((res) => {
					if (res.errorCode === '000000') {
						this.$store.commit('saveUserInfo', res.record);
						if(res.record.cardPicPath) {
							this.coverImgUrl = res.record.cardPicPath
						}
					}
				}).catch(() => {})
			},
		}

	}
</script>
<style>
	page {
		padding: 30rpx;
		box-sizing: border-box;
	}
</style>
<style scoped lang="scss">
	.box .boxImg {
		width: 100%;
		height: 334rpx;
		position: relative;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		background-position: center center;
	}

	.box_image_title_left {
		display: flex;
		align-items: center;
	}

	.box_box {
		width: 100%;
		height: 100%;
		padding: 40rpx;
		box-sizing: border-box;
		position: absolute;
		top: 0;
		left: 0;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.box_image_title {
		display: flex;
		align-items: end;
		justify-content: space-between;
	}

	.box_image_title_left_img {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		background: #ffffff;
		flex-shrink: 0;
		overflow: hidden;
	}

	.box_image_title_left_img image {
		width: 100%;
		height: 100%;
	}

	.box_image_title_left_name {
		display: flex;
		flex-direction: column;
		margin-left: 32rpx;
	}

	.box_image_title_left_name text:nth-child(1) {
		font-size: 36rpx;
		font-weight: 500;
		color: $yellow;
	}

	.box_image_title_left_name text:nth-child(2) {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(249,222,174,0.8);
		margin-top: 10rpx;
	}

	.box_image_title_right {
		padding: 7rpx 16rpx;
		background: $yellow;
		border-radius: 8rpx;
	}
	
	.box_image_title_right text {
		font-size: 22rpx;
		font-weight: 400;
		color: #5A1900;
	}

	.box_image_ye {
		display: flex;
		flex-direction: column;
		view{
			font-size: 26rpx;
			font-weight: 400;
			color: $yellow;
			text {
				font-size: 48rpx;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				margin-right: 8rpx;
				color: $yellow;
			}
		}
	}

	.box_list {
		margin-top: 50rpx;
		view {
			line-height: 110rpx;
			font-size: 32rpx;
			color: #333333;
			border-bottom: 1px solid #E5E5E5;
		}
	}

	.box_footer {
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.box_footer_btn {
		height: 88rpx;
		background: $color;
		border-radius: 44rpx;
		font-size: 30rpx;
		font-weight: 500;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.box_zw {
		height: 150rpx;
	}
</style>
